package cn.wolfcode.luowowo.website.web.controller;

import cn.wolfcode.luowowo.common.util.JsonResult;
import cn.wolfcode.luowowo.website.web.util.UMEditorUploader;
import cn.wolfcode.luowowo.website.web.util.UploadUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UploadController {
    @Value("${file.path}")
    private String filePath;

    //上传图片
    @RequestMapping("/coverImageUpload")
    @ResponseBody
    public Object coverImageUpload(MultipartFile pic){
        String upload = UploadUtil.upload(pic, filePath);
        return upload;
    }

    @RequestMapping("/coverImgUpload")
    @ResponseBody
    public Object uploadImage(MultipartFile pic){
        String filename = UploadUtil.upload(pic, filePath);
        return new JsonResult(true,filename);
    }

}
